﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace KgUtils.Web
{
    public class SortInfo
    {
        public SortInfo(string sortExpression, SortDirection sortDirection)
        {
            SortDirection = sortDirection;

            if (!string.IsNullOrWhiteSpace(sortExpression))
            {
                //try to remove the "DESC" the system may have added
                var splits = sortExpression.Split(' ');
                if (splits.Length > 0)
                    SortExpression = splits[0];
                else
                    SortExpression = sortExpression;
            }
        }

        /*Sorting*/
        public SortDirection SortDirection { get; set; }
        public string SortExpression { get; set; }
    }
}
